#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin >> n;
    string st;
    cin >> st;

    vector<int> s(n), h(n), y(n);
    if (st[0] == 's') s[0] = 1;
    for (int i = 1; i < n; i++)
    {
        if (st[i] == 's')
        {
            s[i] = s[i - 1] + 1;
            h[i] = h[i - 1];
            y[i] = y[i - 1];
        }
        else if (st[i] == 'h')
        {
            s[i] = s[i - 1];
            h[i] = h[i - 1] + s[i];
            y[i] = y[i - 1];
        }
        else if (st[i] == 'y')
        {
            s[i] = s[i - 1];
            h[i] = h[i - 1];
            y[i] = y[i - 1] + h[i];
        }
        else
        {
            s[i] = s[i - 1];
            h[i] = h[i - 1];
            y[i] = y[i - 1];
        }
    }
    cout << y[n - 1];
    return 0;
}